import { NestFactory } from '@nestjs/core';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
import { AppModule } from './app.module';
import { NestExpressApplication } from '@nestjs/platform-express';

async function bootstrap() {
  const app = await NestFactory.create<NestExpressApplication>(AppModule);

  // 自动生成接口文档 npm install --save @nestjs/swagger 地址 https://docs.nestjs.com/openapi/introduction   https://docs.nestjs.com/openapi/introduction
  const config = new DocumentBuilder()
    .setTitle('第一个Nestjs接口文档')
    .setDescription('接口文档描述')
    .setVersion('1.0')
    .addTag('文档')
    .build();
  const documentFactory = () => SwaggerModule.createDocument(app, config);
  SwaggerModule.setup('docs', app, documentFactory);

  await app.listen(process.env.PORT ?? 4000);
}
bootstrap();